<template>
  <div class="header">
    <el-row type="flex" justify="space-between">
      <el-col :span="12">
        <div class="logo">
          <a href="/" id="text">{{ title }}</a>
        </div></el-col
      >
      <el-col :span="10"><Menu></Menu></el-col>
      <el-col :span="2"><Login></Login></el-col>
    </el-row>
  </div>
</template>

<script>
import Menu from "./Menu.vue";
import Login from "./Login.vue";
export default {
  components: { Menu, Login },
  data() {
    return {
      activeIndex: "/",
      circleUrl:
        "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
      title: "",
      i: 0,
    };
  },
  methods: {
    handleSelect() {},
    typeword() {
      let that = this;
      let i = 0,
        timer = 0,
        str = "个人博客";
      function typing() {
        if (i <= str.length) {
          that.title = str.slice(0, i++) + "_";
          timer = setTimeout(typing, 200);
        } else {
          that.title = str; //结束打字,移除 _ 光标
          clearTimeout(timer);
        }
      }

      typing();
      // let str = "个人博客";
      // if (this.i <= str.length) {
      //   this.title = str.slice(0, this.i++) + "_";
      //   this.timer = setTimeout(this.typeword(), 2000);
      // } else {
      //   this.title = str; //结束打字,移除 _ 光标
      //   clearTimeout(this.timer);
      // }
    },
  },
  mounted() {
    this.typeword();
  },
};
</script>


<style lang="less" scoped>
.logo {
  margin-left: 18px;
}
.logo a {
  display: block;
  font-size: 28px;
  color: #666;
  line-height: 48px;
  text-decoration: none;
}
.header {
  position: relative;
  width: 100vw;
  height: 48px;
  .avatar {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
  }
  background-color: #fff;
  // background-color: #409EFF;
}
.el-menu.el-menu--horizontal {
  border: 0 !important;
}
</style>